home *** CD-ROM | disk | FTP | other *** search
/ Aminet 49 / Aminet 49 (2002)(GTI - Schatztruhe)[!][Jun 2002].iso / Aminet / util / misc / ReportPlus.lha / ReportPlus / source / f2.c < prev    next >
C/C++ Source or Header  |  2002-04-15  |  43KB  |  1,276 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <clib/exec_protos.h>
  4. #include <intuition/intuition.h>
  5. #include <clib/intuition_protos.h>
  6. #include <libraries/gadtools.h>
  7. #include <clib/gadtools_protos.h>
  8. #include <graphics/gfx.h>
  9. #include <clib/graphics_protos.h>
  10.  
  11. #include <clib/alib_protos.h>
  12. #include <ctype.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include "rp.h"
  16.  
  17. #define ALL_REACTION_CLASSES
  18. #define ALL_REACTION_MACROS
  19. #include <reaction/reaction.h>
  20. #include <gadgets/texteditor.h>
  21. #include <clib/texteditor_protos.h>
  22. #include <pragmas/texteditor_pragmas.h>
  23. #define ALL_REACTION_CLASSES
  24. #include <reaction/reaction.h>
  25.  
  26. #define MAINTYPES   15
  27. #define CATEGORIES 341
  28. struct
  29. {   ULONG start, end;
  30. } offsets[MAINTYPES + 1] =
  31. {   16,  26, // biz
  32.     27,  47, // comm
  33.     48,  73, // demo
  34.     74,  90, // dev
  35.     91,  97, // disk
  36.     98, 105, // docs
  37.    106, 120, // game
  38.    121, 132, // gfx
  39.    133, 135, // hard
  40.    136, 140, // info
  41.    141, 150, // misc
  42.    151, 261, // mods
  43.    262, 265, // mus
  44.    266, 307, // pix
  45.    308, 318, // text
  46.    319, 341  // util
  47. };
  48.  
  49. AGLOBAL struct AminetStruct aminet;
  50.  
  51. // from rp.c
  52. IMPORT ABOOL                fillwindows;
  53. IMPORT SBYTE                page;
  54. IMPORT TEXT                 IOBuffer[LONGESTFIELD + 1],
  55.                             aslresult[MEDFIELD + 1],
  56.                             string[VLONGFIELD + 1];
  57. IMPORT ULONG                offset;
  58. IMPORT struct NewGadget     Gadget;
  59. IMPORT struct SharedStruct  shared;
  60. IMPORT struct Window*       MainWindowPtr;
  61. IMPORT struct Library*      TextEditorBase;
  62. IMPORT Object*              WinObject[FUNCTIONS + 1]; // note that WindowObject is a reserved macro
  63. IMPORT struct Menu*         MenuPtr;
  64. IMPORT struct Screen*       ScreenPtr;
  65.  
  66. MODULE void updateaminetgadgets(void);
  67. MODULE void readaminetgadgets(void);
  68. MODULE void updatesubtype(void);
  69.  
  70. MODULE ABOOL          MainTypeNodes     = FALSE,
  71.                       SubTypeNodes      = FALSE;
  72. MODULE struct List    MainTypeList,
  73.                       SubTypeList,
  74.                       EmptySubTypeList;
  75.  
  76. MODULE struct Gadget *aminet_gadgets[GIDS_2 + 1];
  77.  
  78. MODULE struct
  79. {   STRPTR name;
  80.     STRPTR desc;
  81. } category[CATEGORIES + 1] =
  82. { // all (0)
  83. "biz",   "Business software",
  84. "comm",  "Communications",
  85. "demo",  "Gfx and sound demos",
  86. "dev",   "Development software",
  87. "disk",  "Disk/Harddisk tools",
  88. "docs",  "Text documents",
  89. "game",  "Games",
  90. "gfx",   "Graphics",
  91. "hard",  "Hardware",
  92. "info",  "General FTP information",
  93. "misc",  "Miscellaneous",
  94. "mods",  "Music modules",
  95. "mus",   "Musical software",
  96. "pix",   "Pictures",
  97. "text",  "Text related",
  98. "util",  "Utilities",
  99. // biz (16)
  100. "cloan", "Cloanto software & support",
  101. "dbase", "Data base software",
  102. "demo",  "Demo versions of commercial software",
  103. "dkg",   "DarkAge software & support",
  104. "dopus", "Directory Opus files",
  105. "haage", "Haage & Partner software & support",
  106. "misc",  "Misc business type soft",
  107. "patch", "Commercial software patches",
  108. "p5",    "phase5 software & support",
  109. "swood", "Softwood products",
  110. "titan", "Titan Computer software",
  111. // comm (27)
  112. "ambos", "AmBoS (BBS) related",
  113. "amiex", "Ami-Express BBS related",
  114. "bbs",   "BBS programs",
  115. "cnet",  "CNET BBS related",
  116. "dlg",   "DLG BBS related",
  117. "fido",  "FIDO software",
  118. "irc",   "Internet Relay Chat software",
  119. "mail",  "Mailing soft",
  120. "maxs",  "MaxsBBS related",
  121. "mebbs", "MEBBSNet BBS related",
  122. "misc",  "Misc communications",
  123. "mmgr",  "MailManager related",
  124. "net",   "Networking",
  125. "news",  "Newsreaders",
  126. "tcp",   "AmiTCP networking",
  127. "term",  "Terminal programs",
  128. "thor",  "Thor mail/news system",
  129. "ums",   "Universal Message System",
  130. "uucp",  "UUCP software",
  131. "www",   "World Wide Web software",
  132. "xeno",  "Xenolink BBS related",
  133. // demo (48)
  134. "40k",   "40K intros",
  135. "aga",   "Demos requiring AGA chipset",
  136. "bse",   "Belgian Scene Event files",
  137. "disk",  "Demos on diskettes",
  138. "ecs",   "Demos for the ECS chip set",
  139. "euro",  "Euro demos in file form",
  140. "file",  "Single file demos",
  141. "funet", "From the Funet collection",
  142. "intro", "Intros",
  143. "mag",   "Demo coder magazines",
  144. "mega",  "Euro demos requiring floppies",
  145. "slide", "Image oriented demos",
  146. "sound", "Sound oriented demos",
  147. "sp96",  "Saturne Party 96 demos",
  148. "ta95",  "Demos from The Assembly 95",
  149. "ta96",  "Demos from The Assembly 96",
  150. "ta97",  "Demos from The Assembly 97",
  151. "tg93",  "The Gathering 1993 demos",
  152. "tg95",  "The Gathering 1995 demos",
  153. "tg96",  "The Gathering 1996 demos",
  154. "tg97",  "The Gathering 1997 demos",
  155. "tp92",  "Demos from The Party 92",
  156. "tp94",  "Demos from The Party 94",
  157. "tp95",  "Demos from The Party 95",
  158. "tp96",  "Demos from The Party 96",
  159. "track", "Trackmos",
  160. // dev (74)
  161. "amos",  "AMOS BASIC compiler",
  162. "asm",   "Assembly language related",
  163. "basic", "BASIC language related",
  164. "c",     "C language related",
  165. "cross", "Cross development",
  166. "debug", "Debugging software",
  167. "e",     "E language related",
  168. "gcc",   "GNU C compiler",
  169. "gg",    "Geek Gadgets GNU software",
  170. "gui",   "GUI builders",
  171. "lang",  "Various languages",
  172. "m2",    "Modula-2 related",
  173. "misc",  "Misc development software",
  174. "moni",  "Monitors/disassemblers",
  175. "mui",   "MagicUserInterface related",
  176. "obero", "Oberon related software",
  177. "src",   "Tutorial sources",
  178. // disk (92)
  179. "bakup", "Backup software",
  180. "cache", "Disk caching",
  181. "cdrom", "CD-ROM related software",
  182. "misc",  "Various disk related tools",
  183. "moni",  "Disk monitors",
  184. "optim", "Disk optimizers",
  185. "salv",  "Disk recovery software",
  186. // docs (99)
  187. "anno",  "Announcement documents",
  188. "etext", "Project Gutenberg books",
  189. "help",  "Help on various issues",
  190. "hyper", "Hypertext documents",
  191. "lists", "Lists and tables",
  192. "mags",  "Magazines",
  193. "misc",  "Various documents",
  194. "rview", "Amiga product reviews",
  195. // game (107)
  196. "2play", "2 and more player games",
  197. "actio", "Action games",
  198. "board", "Board games",
  199. "data",  "Data files for games",
  200. "demo",  "Demos of commercial games",
  201. "gag",   "Gag programs",
  202. "hint",  "Game hint documents",
  203. "jump",  "Jump-n-run games",
  204. "misc",  "Miscellaneous games",
  205. "patch", "Patches for games",
  206. "role",  "Role, adventure games",
  207. "shoot", "Shoot-em-up games",
  208. "text",  "Text based adventures",
  209. "think", "Mind games",
  210. "wb",    "Workbench games",
  211. // gfx  (122)
  212. "3d",    "3D graphics software",
  213. "3dobj", "3D objects",
  214. "aga",   "AGA chip set software",
  215. "board", "Custom gfx board software",
  216. "conv",  "Gfx conversion tools",
  217. "edit",  "Paint programs",
  218. "fract", "Fractals and Mandelbrots",
  219. "ifx",   "ImageFX related files",
  220. "misc",  "Misc graphics software",
  221. "pbm",   "Pbm+ gfx conversion",
  222. "show",  "Image/anim displayers",
  223. "x11",   "Amiga X-Windows",
  224. // hard (134)
  225. "drivr", "Drivers for hardware",
  226. "hack",  "Selfmade hardware",
  227. "misc",  "Misc hardware related files",
  228. // info (137)
  229. "adt",   "Machine readable filelists",
  230. "index", "Various Aminet index files",
  231. "sites", "Info on other FTP sites",
  232. "start", "Beginner information",
  233. "stats", "Statistics about this site",
  234. // misc (142)
  235. "amag",  "German Amiga Mag PD",
  236. "antiq", "Nostalgic stuff",
  237. "edu",   "Educational software",
  238. "emu",   "Emulations",
  239. "imdb",  "Internet Movie Database",
  240. "kids",  "Children's software",
  241. "math",  "Mathematics",
  242. "misc",  "Uncategorizable",
  243. "sci",   "Scientific software",
  244. "unix",  "Amiga related UNIX software",
  245. // mods (152)
  246. "32bit", "MP3s by 32bit choonz",
  247. "4mat",  "Mods by 4mat",
  248. "8voic", "8-voiced songs",
  249. "airon", "Mods by Airon",
  250. "alpma", "Mods by Johan Alpmar",
  251. "atmos", "Atmospheric music",
  252. "aweso", "Mods by Dr Awesome",
  253. "bhead", "Mods by Basehead",
  254. "bladr", "Mods by Black Dragon",
  255. "blk",   "Mods by Black Shadow",
  256. "blkha", "Mods by Blakkhar",
  257. "boing", "Boing collection",
  258. "boray", "Mods by Boray",
  259. "casef", "Mods by Case and Filippetto",
  260. "cato",  "Mods by Don Cato",
  261. "cels",  "Mods by Celsius",
  262. "chart", "Module hits",
  263. "chip",  "Mods without samples",
  264. "chrom", "Mods by Chromag",
  265. "chryl", "Mods by Chrylian",
  266. "clawz", "Mods by Clawz",
  267. "cloud", "Mods by Cloud",
  268. "crash", "Mods by Crash Noise Division",
  269. "crn",   "Mods by Corrosion",
  270. "ctp",   "Mods by Counterpoint",
  271. "cutc",  "Mods by Cutcreator",
  272. "darde", "Mods by Fredius Darde",
  273. "dean",  "Mods by Dean",
  274. "delor", "Mods by Delorean",
  275. "demo",  "Demo style music",
  276. "dizzy", "Mods by Dizzy",
  277. "dlusn", "Mods by D.Lusion",
  278. "doh",   "Mods by Doh",
  279. "dremr", "Mods by Dreamer",
  280. "dsx",   "Mods by DSX",
  281. "elbie", "Mods by Elbie",
  282. "emax",  "Mods by Emax",
  283. "ephnx", "Mods by Euphonix",
  284. "evrim", "Mods by Evrimsson",
  285. "exprt", "Mods by Expert",
  286. "facet", "Mods by Facet",
  287. "fby",   "Mods by Fabio Barzagli",
  288. "fermx", "Mods by Fermix",
  289. "fox2",  "Mods by TheFoxII",
  290. "funet", "Funet collection",
  291. "funk",  "Funky/jazzy mods",
  292. "hardc", "Hardcore techno",
  293. "hje",   "Mods by H.J. Ehrentraud",
  294. "huezo", "Mods by Huezo",
  295. "house", "House modules",
  296. "hw",    "Mods by Hillware",
  297. "inst",  "Instruments for modules",
  298. "instr", "Instrumental music",
  299. "jogei", "Mods by Jogeir Liljedahl",
  300. "jorma", "Mods by Da Jormas (techno)",
  301. "jungl", "Jungle/Breakbeat mods",
  302. "k4k",   "Mods by k4k",
  303. "kaa",   "Mods by Redd Kaa",
  304. "lead",  "Mods by Lead",
  305. "mark",  "Mods by Mark Salud",
  306. "maxym", "Mods by Maxym",
  307. "med",   "MED modules",
  308. "melod", "Melodic modules",
  309. "melom", "Mods by MeloManiac",
  310. "midi",  "Music in MIDI format",
  311. "misc",  "Miscellaneous songs",
  312. "mnc",   "Mods by Meanace",
  313. "mpg",   "Music in MPEG audio format",
  314. "mryo",  "Mods by Mr. Yo",
  315. "mvp",   "Mods by MoPlayaz",
  316. "ncase", "Mods by Nutcase",
  317. "neuro", "Neurodancer's modules",
  318. "nork",  "Mods by Nork",
  319. "ooze",  "Mods by Ooze",
  320. "otis",  "Mods by Otis",
  321. "panik", "Mods by Panik",
  322. "pdy",   "Mods by Prodigy",
  323. "pete",  "Mods by Pirate Pete",
  324. "piano", "Piano mods",
  325. "pop",   "Pop music",
  326. "pro",   "Protracker songs",
  327. "przk",  "Mods by Parsec",
  328. "punn",  "Mods by Punnik",
  329. "purg",  "Mods by Purgatory",
  330. "racoo", "Mods by Racoon", // new for 5.02
  331. "rated", "Misc rated modules",
  332. "rebel", "Mods by Rebel Riffs",
  333. "rock",  "Rock'n'Roll",
  334. "roz",   "Mods by Roz",
  335. "s3m",   "Multichannel s3m mods",
  336. "sbc",   "Modules by Substance",
  337. "sets",  "Module collections",
  338. "sidew", "Mods by Sidewinder",
  339. "slc",   "Mods by Slice",
  340. "slow",  "Slow, melodic modules",
  341. "smg",   "Modes by esemgy",
  342. "smpl",  "Sound samples",
  343. "sonor", "Mods by Sonority",
  344. "spark", "Mods by P.D. Spark",
  345. "stame", "Mods by Stamen",
  346. "synth", "Synthesizer modules",
  347. "techn", "Techno music",
  348. "toady", "Mods by Olivier Gonneau",
  349. "tranc", "Trance techno mods",
  350. "tp96",  "Mods from The Party 1996",
  351. "uns",   "Mods by UnIsOn",
  352. "voice", "Music with voices",
  353. "voy",   "Mods by Voyager",
  354. "wmr",   "Mods reviewed by WMR",
  355. "xceed", "Mods by X-Ceed (ex Snoopy)",
  356. "xm",    "Multichannel xm mods",
  357. // mus (259)
  358. "edit",  "Composing software",
  359. "midi",  "MIDI software",
  360. "misc",  "Miscellaneous",
  361. "play",  "Sound players",
  362. // pix (263)
  363. "3dani", "3D animations",
  364. "addic", "Pictures by 3DAddict",
  365. "anim",  "Animations",
  366. "art",   "Hand drawn imagery",
  367. "astro", "Astronomy pictures",
  368. "back",  "Workbench backdrop pictures",
  369. "bill",  "Bill Graham traces",
  370. "boot",  "Boot pictures",
  371. "clip",  "Clip art",
  372. "eps",   "Structured EPS images",
  373. "eric",  "Eric Schwartz anims",
  374. "fauna", "Animals",
  375. "fract", "Fractals",
  376. "gicon", "GlowIcons",
  377. "glenn", "Traces by Glenn J. Schworak",
  378. "guard", "Guardians traces",
  379. "heiko", "Traces by Heiko Popp",
  380. "henz",  "Traces by Patrick Henz", // new for 5.02
  381. "icon",  "Workbench icons",
  382. "illu",  "Illustrations",
  383. "imagi", "Imagine traces",
  384. "irc",   "The people on IRC",
  385. "jake",  "The Ragtime Gallery",
  386. "jason", "Jason Brown illustration",
  387. "map",   "Images of maps",
  388. "mark",  "Traces by Markus Kuhnen",
  389. "misc",  "Miscellaneous images",
  390. "mpg",   "MPEG animations",
  391. "mwb",   "MagicWB icons",
  392. "nevil", "Pics by Neville Rolle",
  393. "nicon", "NewIcons",
  394. "park",  "Maps of US national parks",
  395. "real3", "Real3D traces",
  396. "sport", "Sports pictures",
  397. "textu", "Textures",
  398. "tp96",  "Pics from The Party 1996",
  399. "trace", "Raytraced pictures",
  400. "unrl",  "Animations by Unreal",
  401. "vehic", "Vehicle images",
  402. "views", "Scenery, countries",
  403. "wb",    "Example WB screens",
  404. "wfm",   "Artwork of William F. Maddock",
  405. // text (303)
  406. "bfont", "Bitmap font collection",
  407. "dtp",   "Desk top publishing",
  408. "edit",  "Editors",
  409. "font",  "Fonts of all formats and related too", // ..."ls"
  410. "hyper", "Hypertext tools",
  411. "ifont", "Intellifont collection",
  412. "misc",  "Misc text software",
  413. "pfont", "Postscript font collection",
  414. "print", "Printing tools",
  415. "show",  "Text displayers",
  416. "tex",   "TeX formatting package",
  417. // util (314)
  418. "app",   "AppIcons, AppWindows",
  419. "arc",   "Archivers",
  420. "batch", "Script software",
  421. "blank", "Screen blankers",
  422. "boot",  "Startup sequence software",
  423. "cdity", "Commodity type software",
  424. "cli",   "Command line interface",
  425. "conv",  "File conversion",
  426. "crypt", "Encryption tools",
  427. "dir",   "Directory utilities",
  428. "dtype", "Datatypes for OS 3.x",
  429. "gnu",   "GNU utilities",
  430. "libs",  "Libraries",
  431. "misc",  "Miscellaneous",
  432. "moni",  "System monitors",
  433. "mouse", "Mouse accelerators",
  434. "pack",  "Packers",
  435. "rexx",  "ARexx tools",
  436. "shell", "Shells",
  437. "sys",   "Common file replacements",
  438. "time",  "Clocks and timing",
  439. "virus", "Virus checkers",
  440. "wb",    "Workbench utilities"
  441. };
  442.  
  443. AGLOBAL void aminet1(void)
  444. {   struct Hook Hook2Struct;
  445.  
  446.     if ((!(aminet.uploader[0])) && readin("S:Report.sender"))
  447.     {   /* # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
  448.            # Path: <email><LF>
  449.            # ReferID: <developer><LF> */
  450.  
  451.         offset = 0;
  452.         parse("# Refer: ");
  453.         parse(",");
  454.         parse(" (");
  455.         parse(" ,phone ");
  456.         parse(")\n# Path: ");
  457.         parse("\n# ReferID: ");
  458.         strcpy(aminet.uploader, string);
  459.     }
  460.  
  461.     /* Create the window object. */
  462.     lockscreen();
  463.     gadtools();
  464.     InitHook(&Hook2Struct, Hook2Func, NULL);
  465.  
  466. if (!(WinObject[2] =
  467. NewObject
  468. (   WINDOW_GetClass(),                    NULL,
  469.     WA_PubScreen,                         ScreenPtr,
  470.     WA_ScreenTitle,                       "Report+",
  471.     WA_Title,                             "Report+: Aminet Readme Editor",
  472.     WA_Activate,                          TRUE,
  473.     WA_DepthGadget,                       TRUE,
  474.     WA_DragBar,                           TRUE,
  475.     WA_CloseGadget,                       TRUE,
  476.     WA_SizeGadget,                        TRUE,
  477.     WA_IDCMP,                             IDCMP_RAWKEY,
  478.     WINDOW_IDCMPHook,                     &Hook2Struct,
  479.     WINDOW_IDCMPHookBits,                 IDCMP_RAWKEY,
  480.     WINDOW_MenuStrip,                     MenuPtr,
  481.     WINDOW_Position,                      WPOS_FULLSCREEN,
  482.     WINDOW_ParentGroup,                   aminet_gadgets[GID_2_LY1] =
  483.     NewObject
  484.     (   LAYOUT_GetClass(),                NULL,
  485.         LAYOUT_Orientation,               LAYOUT_ORIENT_VERT,
  486.         LAYOUT_SpaceOuter,                TRUE,
  487.         LAYOUT_DeferLayout,               TRUE,
  488.         LAYOUT_AddChild,
  489.         NewObject
  490.         (   LAYOUT_GetClass(),            NULL,
  491.             LAYOUT_Orientation,           LAYOUT_ORIENT_HORIZ,
  492.             LAYOUT_SpaceOuter,            TRUE,
  493.             LAYOUT_DeferLayout,           TRUE,
  494.             LAYOUT_BevelStyle,            BVS_FIELD,
  495.             LAYOUT_AddChild,
  496.             NewObject
  497.             (   LAYOUT_GetClass(),        NULL,
  498.                 LAYOUT_Orientation,       LAYOUT_ORIENT_VERT,
  499.                 LAYOUT_SpaceOuter,        TRUE,
  500.                 LAYOUT_VertAlignment,     LALIGN_CENTER,
  501.                 LAYOUT_BevelStyle,        BVS_NONE,
  502.                 LAYOUT_AddChild,
  503.                 NewObject
  504.                 (   LAYOUT_GetClass(),    NULL,
  505.                     LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  506.                     LAYOUT_SpaceOuter,    TRUE,
  507.                     LAYOUT_HorizAlignment,LALIGN_RIGHT,
  508.                     LAYOUT_BevelStyle,    BVS_FIELD,
  509.                     LAYOUT_AddImage,
  510.                     NewObject
  511.                     (   LABEL_GetClass(),     NULL,
  512.                         LABEL_Text,           "_Short:",
  513.                         LABEL_Justification,  LJ_RIGHT,
  514.                     TAG_END),
  515.                 TAG_END),
  516.                 LAYOUT_AddChild,
  517.                 NewObject
  518.                 (   LAYOUT_GetClass(), NULL,
  519.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  520.                     LAYOUT_SpaceOuter,        TRUE,
  521.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  522.                     LAYOUT_BevelStyle,        BVS_FIELD,
  523.                     LAYOUT_AddImage,
  524.                     NewObject
  525.                     (   LABEL_GetClass(),     NULL,
  526.                         LABEL_Text,           "_Uploader:",
  527.                         LABEL_Justification,  LJ_RIGHT,
  528.                     TAG_END),
  529.                 TAG_END),
  530.                 LAYOUT_AddChild,
  531.                 NewObject
  532.                 (   LAYOUT_GetClass(),        NULL,
  533.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  534.                     LAYOUT_SpaceOuter,        TRUE,
  535.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  536.                     LAYOUT_BevelStyle,        BVS_FIELD,
  537.                     LAYOUT_AddImage,          NewObject
  538.                     (   LABEL_GetClass(),     NULL,
  539.                         LABEL_Text,           "_Author:",
  540.                         LABEL_Justification,  LJ_RIGHT,
  541.                     TAG_END),
  542.                 TAG_END),
  543.                 LAYOUT_AddChild,
  544.                 NewObject
  545.                 (   LAYOUT_GetClass(),        NULL,
  546.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  547.                     LAYOUT_SpaceOuter,        TRUE,
  548.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  549.                     LAYOUT_BevelStyle,        BVS_FIELD,
  550.                     LAYOUT_AddImage,
  551.                     NewObject
  552.                     (   LABEL_GetClass(),     NULL,
  553.                         LABEL_Text,           "_Replaces:",
  554.                         LABEL_Justification,  LJ_RIGHT,
  555.                     TAG_END),
  556.                 TAG_END),
  557.                 LAYOUT_AddChild,
  558.                 NewObject
  559.                 (   LAYOUT_GetClass(),        NULL,
  560.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  561.                     LAYOUT_SpaceOuter,        TRUE,
  562.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  563.                     LAYOUT_BevelStyle,        BVS_FIELD,
  564.                     LAYOUT_AddImage,
  565.                     NewObject
  566.                     (   LABEL_GetClass(),     NULL,
  567.                         LABEL_Text,           "R_equires:",
  568.                         LABEL_Justification,  LJ_RIGHT,
  569.                     TAG_END),
  570.                 TAG_END),
  571.                 LAYOUT_AddChild,
  572.                 NewObject
  573.                 (   LAYOUT_GetClass(),        NULL,
  574.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  575.                     LAYOUT_SpaceOuter,        TRUE,
  576.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  577.                     LAYOUT_BevelStyle,        BVS_FIELD,
  578.                     LAYOUT_AddImage,
  579.                     NewObject
  580.                     (   LABEL_GetClass(),     NULL,
  581.                         LABEL_Text,           "_Version:",
  582.                         LABEL_Justification,  LJ_RIGHT,
  583.                     TAG_END),
  584.                 TAG_END),
  585.                 LAYOUT_AddChild,
  586.                 NewObject
  587.                 (   LAYOUT_GetClass(),        NULL,
  588.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  589.                     LAYOUT_SpaceOuter,        TRUE,
  590.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  591.                     LAYOUT_BevelStyle,        BVS_FIELD,
  592.                     LAYOUT_AddImage,
  593.                     NewObject
  594.                     (   LABEL_GetClass(),     NULL,
  595.                         LABEL_Text,           "_Distribution:",
  596.                         LABEL_Justification,  LJ_RIGHT,
  597.                     TAG_END),
  598.                 TAG_END),
  599.             TAG_END),
  600.             CHILD_WeightedWidth,              0,
  601.             LAYOUT_AddChild,
  602.             NewObject
  603.             (   LAYOUT_GetClass(),    NULL,
  604.                 LAYOUT_Orientation,   LAYOUT_ORIENT_VERT,
  605.                 LAYOUT_SpaceOuter,    TRUE,
  606.                 LAYOUT_VertAlignment, LALIGN_CENTER,
  607.                 LAYOUT_HorizAlignment,LALIGN_CENTER,
  608.                 LAYOUT_BevelStyle,    BVS_NONE,
  609.                 LAYOUT_AddChild,      aminet_gadgets[GID_2_ST1] =
  610.                 NewObject
  611.                 (   STRING_GetClass(),    NULL,
  612.                     GA_ID,                GID_2_ST1,
  613.                     GA_TabCycle,          TRUE,
  614.                     STRINGA_TextVal,      aminet.amishort,
  615.                     STRINGA_MinVisible,   20,
  616.                     STRINGA_MaxChars,     40,
  617.                 TAG_END),
  618.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST2] =
  619.                 NewObject
  620.                 (   STRING_GetClass(),    NULL,
  621.                     GA_ID,                GID_2_ST2,
  622.                     GA_TabCycle,          TRUE,
  623.                     STRINGA_TextVal,      aminet.uploader,
  624.                     STRINGA_MinVisible,   20,
  625.                     STRINGA_MaxChars,     40,
  626.                 TAG_END),
  627.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST3] =
  628.                 NewObject
  629.                 (   STRING_GetClass(),    NULL,
  630.                     GA_ID,                GID_2_ST3,
  631.                     GA_TabCycle,          TRUE,
  632.                     STRINGA_TextVal,      aminet.author,
  633.                     STRINGA_MinVisible,   20,
  634.                     STRINGA_MaxChars,     40,
  635.                 TAG_END),
  636.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST4] =
  637.                 NewObject
  638.                 (   STRING_GetClass(),    NULL,
  639.                     GA_ID,                GID_2_ST4,
  640.                     GA_TabCycle,          TRUE,
  641.                     STRINGA_TextVal,      aminet.version,
  642.                     STRINGA_MinVisible,   20,
  643.                     STRINGA_MaxChars,     40,
  644.                 TAG_END),
  645.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST5] =
  646.                 NewObject
  647.                 (   STRING_GetClass(),    NULL,
  648.                     GA_ID,                GID_2_ST5,
  649.                     GA_TabCycle,          TRUE,
  650.                     STRINGA_TextVal,      aminet.replaces,
  651.                     STRINGA_MinVisible,   20,
  652.                     STRINGA_MaxChars,     40,
  653.                 TAG_END),
  654.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST6] =
  655.                 NewObject
  656.                 (   STRING_GetClass(),    NULL,
  657.                     GA_ID,                GID_2_ST6,
  658.                     GA_TabCycle,          TRUE,
  659.                     STRINGA_TextVal,      aminet.requires,
  660.                     STRINGA_MinVisible,   20,
  661.                     STRINGA_MaxChars,     40,
  662.                 TAG_END),
  663.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST7] =
  664.                 NewObject
  665.                 (   STRING_GetClass(),    NULL,
  666.                     GA_ID,                GID_2_ST7,
  667.                     GA_TabCycle,          TRUE,
  668.                     STRINGA_TextVal,      aminet.distribution,
  669.                     STRINGA_MinVisible,   20,
  670.                     STRINGA_MaxChars,     40,
  671.                 TAG_END),
  672.             TAG_END),
  673.         TAG_END),
  674.         CHILD_WeightedHeight,         0,
  675.         LAYOUT_AddChild,
  676.         NewObject
  677.         (   LAYOUT_GetClass(),        NULL,
  678.             LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  679.             LAYOUT_SpaceOuter,        TRUE,
  680.             LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  681.             LAYOUT_BevelStyle,        BVS_NONE,
  682.             LAYOUT_AddImage,
  683.             NewObject
  684.             (   LABEL_GetClass(),     NULL,
  685.                 LABEL_Text,           "_Long description:",
  686.                 LABEL_Justification,  LJ_CENTER,
  687.             TAG_END),
  688.         TAG_END),
  689.         CHILD_WeightedHeight,         0,
  690.         LAYOUT_AddChild,              aminet_gadgets[GID_2_TE1] =
  691.         NewObject
  692.         (   TEXTEDITOR_GetClass(),    NULL,
  693.             GA_ID,                    GID_2_TE1,
  694.             GA_TabCycle,              TRUE,
  695.             GA_RelVerify,             TRUE,
  696.             GA_TEXTEDITOR_ExportWrap, 75,
  697.         TAG_END),
  698.         CHILD_WeightedHeight,         70,
  699.         LAYOUT_AddChild,
  700.         NewObject
  701.         (   LAYOUT_GetClass(),        NULL,
  702.             LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  703.             LAYOUT_SpaceOuter,        TRUE,
  704.             LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  705.             LAYOUT_BevelStyle,        BVS_NONE,
  706.             LAYOUT_AddImage,
  707.             NewObject
  708.             (   LABEL_GetClass(),     NULL,
  709.                 LABEL_Text,           "Directory:",
  710.                 LABEL_Justification,  LJ_CENTER,
  711.             TAG_END),
  712.             CHILD_WeightedWidth,      50,
  713.             LAYOUT_AddImage,
  714.             NewObject
  715.             (   LABEL_GetClass(),     NULL,
  716.                 LABEL_Text,           "Subdirectory:",
  717.                 LABEL_Justification,  LJ_CENTER,
  718.             TAG_END),
  719.             CHILD_WeightedWidth,      50,
  720.         TAG_END),
  721.         CHILD_WeightedHeight,         0,
  722.         LAYOUT_AddChild,
  723.         NewObject
  724.         (   LAYOUT_GetClass(),        NULL,
  725.             LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  726.             LAYOUT_SpaceOuter,        TRUE,
  727.             LAYOUT_HorizAlignment,    LALIGN_CENTER,
  728.             LAYOUT_BevelStyle,        BVS_FIELD,
  729.             LAYOUT_AddChild,          aminet_gadgets[GID_2_LB1] =
  730.             NewObject
  731.             (   LISTBROWSER_GetClass(),NULL,
  732.                 GA_ID,                 GID_2_LB1,
  733.                 GA_RelVerify,          TRUE,
  734.                 GA_TextAttr,           Gadget.ng_TextAttr,
  735.                 LISTBROWSER_Labels,    (ULONG) &MainTypeList,
  736.             TAG_END),
  737.             LAYOUT_AddChild,           aminet_gadgets[GID_2_LB2] =
  738.             NewObject
  739.             (   LISTBROWSER_GetClass(),NULL,
  740.                 GA_ID,                 GID_2_LB2,
  741.                 GA_RelVerify,          TRUE,
  742.                 GA_TextAttr,           Gadget.ng_TextAttr,
  743.                 LISTBROWSER_Labels,    (ULONG) &EmptySubTypeList,
  744.             TAG_END),
  745.         TAG_END),
  746.         CHILD_WeightedHeight,          30,
  747.     TAG_END),
  748. TAG_END)))
  749. {   rq("Can't create ReAction gadgets!");
  750. }
  751. unlockscreen();
  752. openwindow();
  753.  
  754.     SetGadgetAttrs
  755.     (   aminet_gadgets[GID_2_TE1],    MainWindowPtr, NULL,
  756.         GA_TEXTEDITOR_Contents, aminet.textfield
  757.     ); // long description
  758.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_NEW,    NOSUB));
  759.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_OPEN,   NOSUB));
  760.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE,   NOSUB));
  761.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
  762.  
  763.     updatesubtype();
  764.     ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST1]);
  765.     loop();
  766.     readaminetgadgets();
  767.     closewindow();
  768.     // now that the window is closed we can free lists
  769.     aminet_exit();
  770. }
  771.  
  772. AGLOBAL void saveaminet(ABOOL saveas)
  773. {   /*  Short:        <short>
  774.         Uploader:     <uploader>
  775.         Author:       <author>
  776.         Type:         <type>
  777.         Replaces:     <replaces>
  778.         Requires:     <requires>
  779.         Version:      <version>
  780.         Distribution: <distribution>
  781.         
  782.         <long description> */
  783.  
  784.     readaminetgadgets();
  785.  
  786.     strcpy(IOBuffer, "Short:        ");
  787.     strcat(IOBuffer, aminet.amishort);
  788.     strcat(IOBuffer, "\n");
  789.     if (aminet.uploader[0])
  790.     {    strcat(IOBuffer, "Uploader:     ");
  791.             strcat(IOBuffer, aminet.uploader);
  792.         strcat(IOBuffer, "\n");
  793.     }
  794.     if (aminet.author[0])
  795.     {   strcat(IOBuffer, "Author:       ");
  796.         strcat(IOBuffer, aminet.author);
  797.         strcat(IOBuffer, "\n");
  798.     }
  799.     // it's compulsory to select a type
  800.     strcat(IOBuffer, "Type:         ");
  801.     strcat(IOBuffer, aminet.type);
  802.     strcat(IOBuffer, "\n");
  803.     if (aminet.replaces[0])
  804.     {   strcat(IOBuffer, "Replaces:     ");
  805.         strcat(IOBuffer, aminet.replaces);
  806.         strcat(IOBuffer, "\n");
  807.     }
  808.     if (aminet.requires[0])
  809.     {   strcat(IOBuffer, "Requires:     ");
  810.         strcat(IOBuffer, aminet.requires);
  811.         strcat(IOBuffer, "\n");
  812.     }
  813.     if (aminet.version[0])
  814.     {   strcat(IOBuffer, "Version:      ");
  815.         strcat(IOBuffer, aminet.version);
  816.         strcat(IOBuffer, "\n");
  817.     }
  818.     if (aminet.distribution[0])
  819.     {   strcat(IOBuffer, "Distribution: ");
  820.         strcat(IOBuffer, aminet.distribution);
  821.         strcat(IOBuffer, "\n");
  822.     }
  823.     strcat(IOBuffer, "\n");
  824.     strcat(IOBuffer, aminet.textfield);
  825.  
  826.     if (!aminet.output[0] || saveas) // if we need a filename
  827.     {   if (saveasl("Save Aminet Readme", "#?.readme"))
  828.         {   strcpy(aminet.output, aslresult);
  829.             writeout(aminet.output);
  830.     }   }
  831.     writeout(aminet.output);
  832. }
  833.  
  834. AGLOBAL void aminet_exit(void)
  835. {   if (SubTypeNodes)
  836.     {   clearlist(&SubTypeList);
  837.         SubTypeNodes = FALSE;
  838. }   }
  839.  
  840. AGLOBAL void aminet_loop(ULONG gid)
  841. {   ULONG code;
  842.  
  843.     switch(gid)
  844.     {
  845.     case GID_2_LB1:
  846.         /* code is the position within the list, starting from 0. */
  847.         if (!(GetAttr
  848.         (   LISTBROWSER_Selected, aminet_gadgets[GID_2_LB1], (ULONG *) &code
  849.         )))
  850.         {   rq("Unsupported inquiry!"); // should never happen
  851.         }
  852.         aminet.maintype = code;
  853.         aminet.subtype  = 0;
  854.         updatesubtype();
  855.     break;
  856.     case GID_2_LB2:
  857.         /* code is the position within the list, starting from 0. */
  858.         if (!(GetAttr
  859.         (   LISTBROWSER_Selected, aminet_gadgets[GID_2_LB2], (ULONG *) &code
  860.         )))
  861.         {   rq("Unsupported inquiry!"); // should never happen
  862.         }
  863.         aminet.subtype = code;
  864.     break;
  865.     default:
  866.     break;
  867. }   }
  868.  
  869. AGLOBAL void newaminet(ABOOL display)
  870. {   aminet.amishort[0]     =
  871.     aminet.uploader[0]     =
  872.     aminet.author[0]       =
  873.     aminet.requires[0]     =
  874.     aminet.distribution[0] =
  875.     aminet.type[0]         =
  876.     aminet.replaces[0]     =
  877.     aminet.output[0]       =
  878.     aminet.textfield[0]    =
  879.     aminet.maintype        =
  880.     aminet.subtype         = 0;
  881.     strcpy(aminet.version, "1.0");
  882.  
  883.     if (display)
  884.         updateaminetgadgets();
  885. }
  886.  
  887. AGLOBAL void openaminet(void)
  888. {   if (asl("#?.readme"))
  889.     {   loadaminet();
  890.         updateaminetgadgets();
  891. }   }
  892.  
  893. AGLOBAL void loadaminet(void)
  894. {   ABOOL done = FALSE;
  895.     ULONG i, j, slashpos = 0;
  896.     TEXT  tempstring[13];
  897.  
  898.     if (readin(aslresult))
  899.     {   strcpy(aminet.output, aslresult);
  900.         offset = 0;
  901.  
  902.         // Clear all fields.
  903.         aminet.amishort[0]     =
  904.         aminet.uploader[0]     =
  905.         aminet.author[0]       =
  906.         aminet.requires[0]     =
  907.         aminet.distribution[0] =
  908.         aminet.type[0]         =
  909.         aminet.replaces[0]     =
  910.         aminet.output[0]       =
  911.         aminet.textfield[0]    =
  912.         aminet.maintype        =
  913.         aminet.subtype         =
  914.         aminet.version[0]      = 0;
  915.  
  916.         do
  917.         {   parse("\n");
  918.             if (string[0] == 0 || (string[0] == CR && string[1] == 0)) // CR support is for IBM-PC compatibility
  919.             {   done = TRUE;
  920.                 parsetoend();
  921.                 strcpy(aminet.textfield, string);
  922.             } elif (!strncmp(string, "Short:",         6))
  923.             {   for (i =  6; i < strlen(string); i++)
  924.                 {   if (string[i] != ' ')
  925.                     {   strcpy(aminet.amishort,     &string[i]);
  926.                         break;
  927.             }   }   }
  928.             elif (!strncmp(string, "Uploader:",      9))
  929.             {   for (i =  9; i < strlen(string); i++)
  930.                 {   if (string[i] != ' ')
  931.                     {   strcpy(aminet.uploader,     &string[i]);
  932.                         break;
  933.             }   }   }
  934.             elif (!strncmp(string, "Author:",        7))
  935.             {   for (i =  7; i < strlen(string); i++)
  936.                 {   if (string[i] != ' ')
  937.                     {   strcpy(aminet.author,       &string[i]);
  938.                         break;
  939.             }   }   }
  940.             elif (!strncmp(string, "Type:",          5))
  941.             {   for (i =  5; i < strlen(string); i++)
  942.                 {   if (string[i] != ' ')
  943.                     {   // OK, we are now at the start of useful data
  944.                         strcpy(aminet.type, &string[i]);
  945.                         while (aminet.type[slashpos] != '/')
  946.                         {   slashpos++;
  947.                         }
  948.                         // slashpos is now offset of '/'
  949.                         strncpy(tempstring, aminet.type, slashpos);                        tempstring[slashpos] = 0;
  950.                         for (j = 0; j <= MAINTYPES; j++)
  951.                         {   if (!strcmp(tempstring, category[j].name))
  952.                             {   aminet.maintype = j; // set up aminet.maintype
  953.                                 break;
  954.                         }   }
  955.                         slashpos++; // move past '/'
  956.                         for (j = offsets[aminet.maintype].start; j <= offsets[aminet.maintype].end; j++)
  957.                         {   if (!strcmp(&aminet.type[slashpos], category[j].name))
  958.                             {   aminet.subtype = j - offsets[aminet.maintype].start;
  959.                                 break;
  960.                         }   }
  961.                         break;
  962.             }   }   }
  963.             elif (!strncmp(string, "Replaces:",      9))
  964.             {   for (i =  9; i < strlen(string); i++)
  965.                 {   if (string[i] != ' ')
  966.                     {   strcpy(aminet.replaces,     &string[i]);
  967.                         break;
  968.             }   }   }
  969.             elif (!strncmp(string, "Requires:",      9))
  970.             {   for (i =  9; i < strlen(string); i++)
  971.                 {   if (string[i] != ' ')
  972.                     {   strcpy(aminet.requires,     &string[i]);
  973.                         break;
  974.             }   }   }
  975.             elif (!strncmp(string, "Version:",       8))
  976.             {   for (i =  8; i < strlen(string); i++)
  977.                 {   if (string[i] != ' ')
  978.                     {   strcpy(aminet.version,      &string[i]);
  979.                         break;
  980.             }   }   }
  981.             elif (!strncmp(string, "Distribution:", 13))
  982.             {   for (i = 13; i < strlen(string); i++)
  983.                 {   if (string[i] != ' ')
  984.                     {   strcpy(aminet.distribution, &string[i]);
  985.                         break;
  986.         }   }   }   }
  987.         while (!done);
  988. }   }
  989.  
  990. MODULE void updateaminetgadgets(void)
  991. {   SetGadgetAttrs
  992.     (   aminet_gadgets[GID_2_ST1], MainWindowPtr, NULL,
  993.         GTST_String, aminet.amishort,
  994.         TAG_END
  995.     );
  996.     SetGadgetAttrs
  997.     (   aminet_gadgets[GID_2_ST2], MainWindowPtr, NULL,
  998.         GTST_String, aminet.uploader,
  999.         TAG_END
  1000.     );
  1001.     SetGadgetAttrs
  1002.     (   aminet_gadgets[GID_2_ST3], MainWindowPtr, NULL,
  1003.         GTST_String, aminet.author,
  1004.         TAG_END
  1005.     );
  1006.     SetGadgetAttrs
  1007.     (   aminet_gadgets[GID_2_ST4], MainWindowPtr, NULL,
  1008.         GTST_String, aminet.version,
  1009.         TAG_END
  1010.     );
  1011.     SetGadgetAttrs
  1012.     (   aminet_gadgets[GID_2_ST5], MainWindowPtr, NULL,
  1013.         GTST_String, aminet.replaces,
  1014.         TAG_END
  1015.     );
  1016.     SetGadgetAttrs
  1017.     (   aminet_gadgets[GID_2_ST6], MainWindowPtr, NULL,
  1018.         GTST_String, aminet.requires,
  1019.         TAG_END
  1020.     );
  1021.     SetGadgetAttrs
  1022.     (   aminet_gadgets[GID_2_ST7], MainWindowPtr, NULL,
  1023.         GTST_String, aminet.distribution,
  1024.         TAG_END
  1025.     );
  1026.     SetGadgetAttrs // `Type'
  1027.     (   aminet_gadgets[GID_2_LB1],
  1028.         MainWindowPtr, NULL,
  1029.         LISTBROWSER_Selected, aminet.maintype,
  1030.         TAG_END
  1031.     );
  1032.  
  1033.     updatesubtype();
  1034.  
  1035.     SetGadgetAttrs
  1036.     (   aminet_gadgets[GID_2_TE1], MainWindowPtr, NULL,
  1037.         GA_TEXTEDITOR_Contents, aminet.textfield,
  1038.         TAG_DONE
  1039.     );
  1040.     // It would be polite to scroll the listviews so that the selected
  1041.     // entries are visible.
  1042. }
  1043. MODULE void readaminetgadgets(void)
  1044. {   STRPTR stringptr;
  1045.  
  1046.     if (!(GetAttr
  1047.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST1], (ULONG *) &stringptr
  1048.     )))
  1049.     {   rq("Unsupported inquiry!"); // should never happen
  1050.     }
  1051.     strcpy(aminet.amishort, stringptr);
  1052.  
  1053.     if (!(GetAttr
  1054.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST2], (ULONG *) &stringptr
  1055.     )))
  1056.     {   rq("Unsupported inquiry!"); // should never happen
  1057.     }
  1058.     strcpy(aminet.uploader, stringptr);
  1059.  
  1060.     if (!(GetAttr
  1061.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST3], (ULONG *) &stringptr
  1062.     )))
  1063.     {   rq("Unsupported inquiry!"); // should never happen
  1064.     }
  1065.     strcpy(aminet.author, stringptr);
  1066.  
  1067.     if (!(GetAttr
  1068.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST4], (ULONG *) &stringptr
  1069.     )))
  1070.     {   rq("Unsupported inquiry!"); // should never happen
  1071.     }
  1072.     strcpy(aminet.replaces, stringptr);
  1073.  
  1074.     if (!(GetAttr
  1075.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST5], (ULONG *) &stringptr
  1076.     )))
  1077.     {   rq("Unsupported inquiry!"); // should never happen
  1078.     }
  1079.     strcpy(aminet.requires, stringptr);
  1080.  
  1081.     if (!(GetAttr
  1082.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST6], (ULONG *) &stringptr
  1083.     )))
  1084.     {   rq("Unsupported inquiry!"); // should never happen
  1085.     }
  1086.     strcpy(aminet.version, stringptr);
  1087.  
  1088.     if (!(GetAttr
  1089.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST7], (ULONG *) &stringptr
  1090.     )))
  1091.     {   rq("Unsupported inquiry!"); // should never happen
  1092.     }
  1093.     strcpy(aminet.distribution, stringptr);
  1094.  
  1095.     strcpy(aminet.type, category[aminet.maintype].name);
  1096.     strcat(aminet.type, "/");
  1097.     strcat(aminet.type, category[offsets[aminet.maintype].start + aminet.subtype].name);
  1098.  
  1099.     stringptr = (STRPTR) DoGadgetMethod
  1100.     (   aminet_gadgets[GID_2_TE1], MainWindowPtr, NULL,
  1101.         GM_TEXTEDITOR_ExportText, NULL
  1102.     );
  1103.     strcpy(aminet.textfield, stringptr); // long description
  1104.     FreeVec((APTR) stringptr);
  1105.     // textBuffer = NULL;
  1106. }
  1107.  
  1108. AGLOBAL void aminet_init(void)
  1109. {   ULONG        i, j, temp;
  1110.     struct Node* ListBrowserNodePtr;
  1111.  
  1112.     NewList(&MainTypeList);
  1113.     MainTypeNodes = TRUE;
  1114.  
  1115.     for (i = 0; i <= MAINTYPES; i++)
  1116.     {   strcpy(string, category[i].name);
  1117.         temp = 5 - strlen(category[i].name);
  1118.         for (j = 1; j <= temp; j++)
  1119.             strcat(string, " ");
  1120.         strcat(string, category[i].desc);
  1121.  
  1122.         if (!(ListBrowserNodePtr = AllocListBrowserNode
  1123.         (    1,                   // columns,
  1124.              LBNA_Column,         0,
  1125.              LBNCA_CopyText,      TRUE,
  1126.              LBNCA_Text,          string,
  1127.              TAG_END
  1128.         )))
  1129.         {   rq("Can't create ReAction listbrowser.gadget node(s)!");
  1130.         }
  1131.         AddTail(&MainTypeList, ListBrowserNodePtr); // AddTail() has no return code
  1132.     }
  1133.  
  1134.     SetGadgetAttrs // `Type'
  1135.     (   aminet_gadgets[GID_2_LB1],
  1136.         MainWindowPtr, NULL,
  1137.         LISTBROWSER_Labels, &MainTypeList,
  1138.         LISTBROWSER_Selected, aminet.maintype,
  1139.         TAG_END
  1140.     );
  1141.  
  1142.     NewList(&SubTypeList);
  1143.     NewList(&EmptySubTypeList);
  1144. }
  1145.  
  1146. AGLOBAL void aminet_die(void)
  1147. {   if (MainTypeNodes)
  1148.     {   clearlist(&MainTypeList);
  1149.         MainTypeNodes = FALSE;
  1150. }   }
  1151.  
  1152. MODULE void updatesubtype(void)
  1153. {   ULONG        i, j, temp;
  1154.     struct Node* ListBrowserNodePtr;
  1155.      
  1156.     SetGadgetAttrs // `Subtype'
  1157.     (   aminet_gadgets[GID_2_LB2],
  1158.         MainWindowPtr, NULL,
  1159.         LISTBROWSER_Labels, NULL, // detach it
  1160.         TAG_END
  1161.     );
  1162.  
  1163.     if (SubTypeNodes)
  1164.     {   clearreactionlist(&SubTypeList);
  1165.     }
  1166.  
  1167.     SubTypeNodes = TRUE;
  1168.     for
  1169.     (   i = offsets[aminet.maintype].start;
  1170.         i <= offsets[aminet.maintype].end;
  1171.         i++
  1172.     )
  1173.     {   strcpy(string, category[i].name);
  1174.         temp = 6 - strlen(category[i].name);
  1175.         for (j = 1; j <= temp; j++)
  1176.             strcat(string, " ");
  1177.         strcat(string, category[i].desc);
  1178.  
  1179.         if (!(ListBrowserNodePtr = AllocListBrowserNode
  1180.         (    1,                   // columns,
  1181.              LBNCA_CopyText,      TRUE,
  1182.              LBNCA_Text,          string,
  1183.              TAG_END
  1184.         )))
  1185.         {   rq("Can't create ReAction listbrowser.gadget node(s)!");
  1186.         }
  1187.         AddTail(&SubTypeList, ListBrowserNodePtr); // AddTail() has no return code
  1188.     }
  1189.  
  1190.     SetGadgetAttrs // `Subtype'
  1191.     (   aminet_gadgets[GID_2_LB2],
  1192.         MainWindowPtr, NULL,
  1193.         LISTBROWSER_Labels, &SubTypeList,
  1194.         LISTBROWSER_Selected, aminet.subtype,
  1195.         TAG_END
  1196.     );
  1197. }
  1198.  
  1199. AGLOBAL ULONG Hook2Func(struct Hook *h, VOID *o, VOID *msg)
  1200. {   /* "When the hook is called, the data argument points to the 
  1201.     window object and message argument to the IntuiMessage." */
  1202.  
  1203.     UWORD code, qual;
  1204.     ULONG scroll = 0;
  1205.  
  1206.     geta4(); // wait till here before doing anything
  1207.  
  1208.     code = ((struct IntuiMessage *) msg)->Code;
  1209.     qual = ((struct IntuiMessage *) msg)->Qualifier;
  1210.  
  1211.     switch(code)
  1212.     {
  1213.     case SCAN_HELP:
  1214.         helpabout();
  1215.     break;
  1216.     case SCAN_ESCAPE:
  1217.         if ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT))
  1218.         {   cleanexit(EXIT_SUCCESS);
  1219.         } else page = 0;
  1220.     break;
  1221.     case SCAN_UP:
  1222.         if (qual & IEQUALIFIER_CONTROL)
  1223.         {   scroll = LBP_TOP;
  1224.         } elif (qual & IEQUALIFIER_LSHIFT || qual & IEQUALIFIER_RSHIFT)
  1225.         {   scroll = LBP_PAGEUP;
  1226.         } else scroll = LBP_LINEUP;
  1227.     break;
  1228.     case SCAN_DOWN:
  1229.         if (qual & IEQUALIFIER_CONTROL)
  1230.         {   scroll = LBP_BOTTOM;
  1231.         } elif (qual & IEQUALIFIER_LSHIFT || qual & IEQUALIFIER_RSHIFT)
  1232.         {   scroll = LBP_PAGEDOWN;
  1233.         } else scroll = LBP_LINEDOWN;
  1234.     break;
  1235.     case SCAN_S:
  1236.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST1]);
  1237.     break;
  1238.     case SCAN_U:
  1239.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST2]);
  1240.     break;
  1241.     case SCAN_A:
  1242.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST3]);
  1243.     break;
  1244.     case SCAN_R:
  1245.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST4]);
  1246.     break;
  1247.     case SCAN_E:
  1248.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST5]);
  1249.     break;
  1250.     case SCAN_V:
  1251.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST6]);
  1252.     break;
  1253.     case SCAN_D:
  1254.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST7]);
  1255.     break;
  1256.     case SCAN_L:
  1257.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_TE1]);
  1258.     break;
  1259.     default:
  1260.     break;
  1261.     }
  1262.  
  1263.     if (code == SCAN_UP || code == SCAN_DOWN)
  1264.     {   SetGadgetAttrs
  1265.         (   aminet_gadgets[GID_2_LB2],    // pointer to gadget
  1266.             MainWindowPtr,                // pointer to window (not window object!)
  1267.             NULL,                         // pointer to requester
  1268.             LISTBROWSER_Position, scroll, // tags
  1269.             TAG_DONE                      // done
  1270.         );
  1271.     }
  1272.  
  1273.     return(1);
  1274. }
  1275.  
  1276.